package com.fss.approval1.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fss.common.annotation.Log;
import com.fss.common.core.controller.BaseController;
import com.fss.common.core.domain.AjaxResult;
import com.fss.common.enums.BusinessType;
import com.fss.approval1.domain.LoanApproval1;
import com.fss.approval1.service.ILoanApproval1Service;
import com.fss.common.utils.poi.ExcelUtil;
import com.fss.common.core.page.TableDataInfo;

/**
 * 贷款审核Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/approval1/approval1")
public class LoanApproval1Controller extends BaseController
{
    @Autowired
    private ILoanApproval1Service loanApproval1Service;

    /**
     * 查询贷款审核列表
     */
    @PreAuthorize("@ss.hasPermi('approval1:approval1:list')")
    @GetMapping("/list")
    public TableDataInfo list(LoanApproval1 loanApproval1)
    {
        startPage();
        List<LoanApproval1> list = loanApproval1Service.selectLoanApproval1List(loanApproval1);
        return getDataTable(list);
    }

    /**
     * 导出贷款审核列表
     */
    @PreAuthorize("@ss.hasPermi('approval1:approval1:export')")
    @Log(title = "贷款审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LoanApproval1 loanApproval1)
    {
        List<LoanApproval1> list = loanApproval1Service.selectLoanApproval1List(loanApproval1);
        ExcelUtil<LoanApproval1> util = new ExcelUtil<LoanApproval1>(LoanApproval1.class);
        util.exportExcel(response, list, "贷款审核数据");
    }

    /**
     * 获取贷款审核详细信息
     */
    @PreAuthorize("@ss.hasPermi('approval1:approval1:query')")
    @GetMapping(value = "/{approvalId}")
    public AjaxResult getInfo(@PathVariable("approvalId") Long approvalId)
    {
        return success(loanApproval1Service.selectLoanApproval1ByApprovalId(approvalId));
    }

    /**
     * 新增贷款审核
     */
    @PreAuthorize("@ss.hasPermi('approval1:approval1:add')")
    @Log(title = "贷款审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LoanApproval1 loanApproval1)
    {
        return toAjax(loanApproval1Service.insertLoanApproval1(loanApproval1));
    }

    /**
     * 修改贷款审核
     */
    @PreAuthorize("@ss.hasPermi('approval1:approval1:edit')")
    @Log(title = "贷款审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LoanApproval1 loanApproval1)
    {
        return toAjax(loanApproval1Service.updateLoanApproval1(loanApproval1));
    }

    /**
     * 删除贷款审核
     */
    @PreAuthorize("@ss.hasPermi('approval1:approval1:remove')")
    @Log(title = "贷款审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{approvalIds}")
    public AjaxResult remove(@PathVariable Long[] approvalIds)
    {
        return toAjax(loanApproval1Service.deleteLoanApproval1ByApprovalIds(approvalIds));
    }
}
